﻿using DataLayer.Model;
using DataLayer.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autofac;

namespace DataLayer
{
    public class UnitOfWork : IDisposable
    {
        #region Properties

        public GameUPContext Context { get; internal set; }

        public CheerMessageRepository CheerMessageRepository { get; internal set; }

        public IndoorExercisePersonalRepository IndoorExercisePersonalRepository { get; internal set; }

        public MessageRepository MessageRepository { get; internal set; }

        public SetTobBoxRepository SetTopBoxRepository { get; internal set; }

        public PlayerRepository PlayerRepository { get; internal set; }

        public PlayerGroupRepository PlayerGroupRepository { get; internal set; }

        public FitbitAccountRepository FitbitAccountRepository { get; internal set; }
        #endregion

        public static UnitOfWork CreateIntance()
        {
            return IocContanier.Current.Resolve<UnitOfWork>();
        }

        private UnitOfWork() { }
        
        #region Public Methods
        public void Commit()
        {
            Context.SaveChanges();
        }

        public void Dispose()
        {
            Context.Dispose();
        }
        #endregion
    }
}
